package com.zygame.sdk.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zygame.sdk.R;
import com.zygame.sdk.utils.util.Purchase;

import java.util.List;

/**
 * @author duguodong
 * @time 2019/3/2
 * @des ${TODO}
 */
public class PurchaseAdapter extends BaseAdapter {
    private List<Purchase> mDatas;
    private int flag;

    public PurchaseAdapter(List<Purchase> datas, int i) {
        mDatas = datas;
        flag = i;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.zy_pay_list_item_purchase_layout, null);
            holder.mImageView = (ImageView) convertView.findViewById(R.id.iv_head);
            holder.mTitle = (TextView) convertView.findViewById(R.id.tv_title);
            holder.mPrice = (TextView) convertView.findViewById(R.id.tv_price);
            holder.mPurchase = (TextView) convertView.findViewById(R.id.tv_purchase);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }

        Purchase skuDetail = mDatas.get(position);
        holder.mTitle.setText("合适的");
        holder.mPrice.setText("阿斯加德");
        if(flag == 2){
            holder.mPurchase.setText("取消订阅");
        }

        return convertView;
    }


    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }


    class ViewHolder {
        private TextView mTitle;
        private TextView mPrice;
        private TextView mPurchase;
        private ImageView mImageView;
    }

}
